package net.hn.hnms.biz.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.hn.hnms.biz.project.domain.ProjectContent;
import net.hn.hnms.biz.project.request.ProjectContentReq;
import net.hn.hnms.biz.project.vo.ProjectContentVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProjectContentMapper extends BaseMapper<ProjectContent> {
    @Update("<script>" +
            " update  project_content set  del_flag = '1' " +
            " where project_content_id in" +
            " <foreach collection=\"list\" item=\"value\" separator=\",\" open=\"(\" close=\")\">\n" +
            "#{value}" +
            "</foreach>" +
            "</script>")
    void updateDeleteByIds(@Param("list") List<String> list);

    @Select("<script>" +
            " select  " +
            " pc.project_content_id projectContentId, " +
            " pc.project_id projectId, " +
            " pc.project_content_code projectContentCode, " +
            " pc.project_content_info projectContentInfo, " +
            " pc.supplier_id supplierId, " +
            " pc.remark,pc.create_time createTime, " +
            " si.supplier_name supplierName " +
            " FROM " +
            " project_content pc " +
            " LEFT JOIN supplier_info si ON pc.supplier_id = si.supplier_id and si.del_flag = '0' " +
            " WHERE " +
            " pc.del_flag = '0' " +
            " order by pc.create_time desc" +
            "  </script>")
    Page<ProjectContentVo> selectPageList(Page<Object> build, @Param("query") ProjectContentReq query);
}
